<% admin_breadcrumb("#{Spree.t(:receiving)} #{@stock_transfer.number}") %>


<% content_for :page_actions do %>
  <li>
    <%= button_link_to Spree.t(:back_to_stock_transfers_list), admin_stock_transfers_path %>
  </li>
  <li>
    <%= button_link_to Spree.t(:close),
      close_admin_stock_transfer_path(@stock_transfer),
      method: 'put',
      data: { confirm: Spree.t('close_stock_transfer.confirm') } %>
  </li>
<% end %>

<div id='stock_transfer_summary' class='fullwidth'>
  <%= render 'spree/admin/stock_transfers/location', stock_transfer: @stock_transfer %>
  <div class='count-summary'>
    <span id='total-received-quantity'><%= @stock_transfer.received_item_count %></span>
    /
    <span><%= @stock_transfer.expected_item_count %></span>
    <span class='summary-field'><%= Spree.t(:received) %></span>
  </div>
</div>

<fieldset>
  <legend align="center"><%= Spree.t(:variant_to_be_received) %></legend>
  <div data-hook="transfer_item_selection">
    <%= hidden_field_tag :stock_transfer_number, @stock_transfer.number %>
    <%= hidden_field_tag :variant_display_attributes, @variant_display_attributes.to_json %>
    <%= text_field_tag :transfer_item_variant_id, "", :class => "variant_autocomplete fullwidth" %>
  </div>
</fieldset>

<fieldset id='received-transfer-items'>
  <legend align="center"><%= Spree.t(:received_items) %></legend>
  <%= render partial: 'transfer_item_table', locals: { transfer_items: @received_items, show_expected: false, show_received: true, show_actions: true } %>
</fieldset>
